<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/3/8
  Time: 13:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增角色</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link href="/static/css/common.css" rel="stylesheet">
    <link href="/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">
    <link rel="stylesheet"
          href="/static/plugins/zTree_v3-3.5.22/css/zTreeStyle/zTreeStyle.css"
          type="text/css">
    <script type="text/javascript" src="/static/js/jquery-1.11.3.min.js"></script>
    <script src="/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/static/plugins/zTree_v3-3.5.22/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="/static/plugins/zTree_v3-3.5.22/js/jquery.ztree.excheck.js"></script>
</head>
<body>
<div class="col-sm-12">
    <form class="form-horizontal m-t" id="form" method="post" action="/admin/role_add.action">
        <div class="col-sm-6">
            <div class="form-group">
                <label class="col-sm-3  control-label"><i class="require">*</i>角色名:</label>
                <div class="col-sm-8">
                    <input class="form-control" name="rName" size="30" required/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3  control-label"><i class="require">*</i>层级:</label>
	            <div class="col-sm-8">
	                <select name="rLevel" id="rLevel"  class="form-control">
	                    <option value="0">平台</option>
	                    <option value="1">公司</option>
	                    <option value="2">社区</option>
	                </select>
	            </div>
            </div>
            <div class="form-group">
               <label class="col-sm-3  control-label"><i class="require">*</i>状态:</label>
            <div class="col-sm-8">
                <select name="status" id="status"  class="form-control">
                    <option value="1">激活</option>
                    <option value="0">禁止</option>
                </select>
            </div>
        </div>
        </div>
        <div class="col-sm-6">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">权限设置</h3>
                </div>
                <div class="panel-body">
                    <input type="hidden" name="mList" id="mList">
                    <div class="col-sm-8">
                        <ul id="auths" class="ztree"></ul>
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">

    var ztree;

    var setting = {
        check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true
            }
        }, callback: {
            onCheck: check
        }
    };

    setting.check.chkboxType = {"Y": "p", "N": "s"};

    $(document).ready(function () {

        $.post("/admin/auth_tree.action", function (result) {
            ztree = $.fn.zTree.init($("#auths"), setting, result);
            ztree.expandAll(true);
        }, "json");
    });

    function check() {
        var checks = new Array();
        var nodes = ztree.getCheckedNodes(true);
        for (var i in nodes) {
            checks.push(nodes[i].id);
        }
        $("#mList").val(checks.toString().replace(/,/g,"|"));
    }
</script>
</body>
</html>
